<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.ag.contactTree.*"%>
<%@page import="com.ag.zhh.vo.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title></title>
		<meta content="text/html; charset=UTF-8" http-equiv="content-type">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		
		<link rel="stylesheet" href="../jquery-treeview/jquery.treeview.css" />
		<link rel="stylesheet" href="../zhh/css/utils.css" />
		
		<script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
		<script src="../jquery-treeview/lib/jquery.cookie.js" type="text/javascript"></script>
		<script src="../jquery-treeview/jquery.treeview.js"
			type="text/javascript"></script>
		<script src="../zhh/js/maintaincontact.js"
			type="text/javascript"></script>
			
		<script>
//step为框架尺寸改变的速度步长
//flag为判断当前状态是显示(1)还是隐藏(-1)
var obj,w,step=100,flag=-1;         
function showHideFrame(b){
		
       obj=parent.frames['treeFrameSet'];        //目标框架对象
       
      // alert(b);      
       w=parseInt(obj.cols.split(",")[0]);      
/*目标框架对象的当前宽度，本例中obj.cols取得的值为"100,*"(显示状态时为"0,*")，obj.cols.split(",")把 obj.cols以","为标志分组，得到数组["100","*"]，obj.cols.split(",")[0]取到数组的第一个元素100，然后用parseInt(obj.cols.split(",")[0])转化为整数*/
       flag=b;                //根据参数值b，设置显示隐藏状态
       resize();                //调用resize()函数
}
function resize(){
//调整目标框架对象宽度值，如果flag为1即显示框架时w不断变大，
//反之不断变小
		
       w += step*flag;
       if((flag==-1&&w>190)||(flag==1&&w<477)){
//隐藏状态并且w大于0或者显示状态并且w<100，执行下面的代码
		//alert(w);
          obj.cols=w+",6,*";                 //重设框架宽度
           //setTimeout("resize()",10); //10毫秒后再次执行resize()函数
       }
}
</script> 
	</head>

	<body style="background-image: url(../images/main_23_3.gif); background-repeat: repeat-y;">
		<div>
			<img src="../zhh/images/Arrow1 Left.gif" onclick="showHideFrame(-1)">
			<img src="../zhh/images/Arrow1 Right.gif" onclick="showHideFrame(1)">
		</div>
		<select id="treeType">
			<!--  	<option value="0001" selected="selected">监督单位</option>
			<option value="0002" >应急部门</option>
			<option value="0003" >外协单位</option>-->
			
		<% Object depts= request.getAttribute("depts");
			String treeType = (String)request.getAttribute("treeType");
			if(depts!=null && !depts.getClass().equals(String.class))
			{
			List<com.ag.bean.TbDeptType>list=(List<com.ag.bean.TbDeptType>)depts;			//部门类型
				for(com.ag.bean.TbDeptType deptType:list)
					{
						if("0000".equals(deptType.getDtId())){
							continue;
						}
						if(treeType.equals(deptType.getDtId())) {
							out.println("<option value='"+deptType.getDtId()+"' selected>"+deptType.getDtName()+"</option>");
							continue;
						}
						out.println("<option value='"+deptType.getDtId()+"'>"+deptType.getDtName()+"</option>");
					}
			}
		%>
			
		
		</select>
		<input type="text" id="text" class="input"><span style="width:20">&nbsp;</span><input type="button" id="find" value="查询" class="button"><input type="button" id="clear" value="清除" class="button">
		 <%-- <%!public void printOATree(TreeNode node, ServletRequest request,
			ServletResponse response, JspWriter out) throws Exception {
		if (node != null) {
			out.println("<li><span class='deptclick' value='"+node.getNodeId()+"'>" + ((Dept) node.getBindData()).getDName()+"</span>");
			List childrenlist = node.getChildren();
			if (childrenlist.size() > 0) {
				out.println("<ul>");
				for (int i = 0; i < childrenlist.size(); i++) {
					TreeNode cnode = (TreeNode) childrenlist.get(i);
					printOATree(cnode, request, response, out);
				}
				out.println("</ul>");
			}
			out.println("</li>");
		}
	}%>--%>
	<%!public void printLcTree(TreeNode node, ServletRequest request,
			ServletResponse response, JspWriter out) throws Exception {
		if (node != null) {
			out.println("<li><span class='deptclick' value='"+node.getNodeId()+"'>" + ((UserDept) node.getBindData()).getUdName()+"</span>");
			List childrenlist = node.getChildren();
			if (childrenlist.size() > 0) {
				out.println("<ul>");
				for (int i = 0; i < childrenlist.size(); i++) {
					TreeNode cnode = (TreeNode) childrenlist.get(i);
					printLcTree(cnode, request, response, out);
				}
				out.println("</ul>");
			}
			out.println("</li>");
		}
	}%>
	
		<!-- 药监内部树 -->
		<!--  
		<div id="contree1">
			<div id="contreecontrol1">
				<a href="?#">关闭所有结点</a> |
				<a href="?#">打开所有节点</a> 
			</div>
			<div style="padding-top:3px;padding-left:75px;">
				<input type="button" value="同步内部通信录" style="border:none;width:90px;height:25px;margin:2px;background-color:#c0c0c0;">
			</div> 
			<ul id="MedicineTree">
				<%--
				TreeNode medicineTreeRoot=null;
			
				Object treeRootObj= request.getAttribute("MedicineTreeRoot");
				if(treeRootObj!=null && !treeRootObj.getClass().equals(String.class)){
						 medicineTreeRoot = (TreeNode)request.getAttribute("MedicineTreeRoot");
				
					printOATree(medicineTreeRoot, request, response, out);
				
				}
			
				--%>			
			</ul>
		</div>
	  -->
	  
	  <div>
			<div id="contactTreecontrol">
				<a href="?#">关闭所有结点</a> |
				<a href="?#">打开所有节点</a>
			</div>

			<ul id="contactTree">
				<%
					TreeNode treeRoot = null;
						Object treeRootTempObj = request.getAttribute("treeRoot");
						if (treeRootTempObj != null
								&& !treeRootTempObj.getClass().equals(String.class)) {
							treeRoot = (TreeNode) treeRootTempObj;
							//if("0000".equals(treeType)) {
							//	printOATree(treeRoot, request, response, out);
							//}else {
								
								printLcTree(treeRoot, request, response, out);
							//}

						}
				%>
			</ul>
		</div>
	   <%-- 
		<!-- 协调部门树 -->
		<div id="contree2">
			<div id="contreecontrol2">
				<a href="?#">关闭所有结点</a> |
				<a href="?#">打开所有节点</a>
			</div>
			<ul id="CoordinatTree" >
				<%
				TreeNode coordinatTreeRoot = null;
				Object treeRootObj2= request.getAttribute("CoordinatTreeRoot");
				if(treeRootObj2!=null && !treeRootObj2.getClass().equals(String.class)){	
					coordinatTreeRoot = (TreeNode)treeRootObj2;
					printLcTree(coordinatTreeRoot, request, response, out);}
				
				%>
			</ul>
		</div>
		
		<!-- 应急部门树 -->
		<div id="contree3" style="display:none">
			<div id="contreecontrol3">
				<a href="?#">关闭所有结点</a> |
				<a href="?#">打开所有节点</a>
			</div>
			<ul id="EmergencyTree">
				<%
				TreeNode emergencyTreeRoot=null;
				Object treeRootObj3= request.getAttribute("EmergencyTreeRoot");
				if(treeRootObj3!=null && !treeRootObj3.getClass().equals(String.class)){
					 emergencyTreeRoot = (TreeNode)request.getAttribute("EmergencyTreeRoot");
					printLcTree(emergencyTreeRoot, request, response, out);
				}
				
				%>
			</ul>
		</div>
		
		<!-- 外单位树 -->
		<div id="contree4" style="display:none">
			<div id="contreecontrol4">
				<a href="?#">关闭所有结点</a> |
				<a href="?#">打开所有节点</a>
			</div>
			<ul id="ExternalTree">
				<%TreeNode externalTreeRoot=null;
				Object treeRootObj4= request.getAttribute("ExternalTreeRoot");
				if(treeRootObj4!=null && !treeRootObj4.getClass().equals(String.class)){
					externalTreeRoot = (TreeNode)request.getAttribute("ExternalTreeRoot");
					printLcTree(externalTreeRoot, request, response, out);
				}
					
				%>
			</ul>
		</div>--%>	
	</body>
</html>